Ruby vs. Bruce¶
Track height and weight of the kids.
In [1]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import datetime as dt
import make_data as mkd
import plotly.express as px
import plotly.io as pio
pio.templates.default = "none"
pio.renderers.default = 'notebook'
In [2]:
data = mkd.load_all_data()
df_m = data
df_m["date"] = pd.to_datetime(df_m["date"], format = "%d/%m/%Y")
df_m["birth_date"] = df_m.groupby("name")["date"].transform("first")
df_m["age_days"] = (df_m["date"] - df_m["birth_date"])
df_m["age_days"] = pd.to_numeric(df_m["age_days"].dt.days)
df_m["weight_kg"] = df_m["weight_grams"]/1000
df_m.head()
Out[2]:
| name | date | height_cm | weight_grams | head_circ_cm | birth_date | age_days | weight_kg | |
|---|---|---|---|---|---|---|---|---|
| 0 | Dad | 1987-02-28 | 53.0 | 4370 | 36.5 | 1987-02-28 | 0 | 4.37 |
| 1 | Dad | 1987-03-11 | NaN | 3930 | NaN | 1987-02-28 | 11 | 3.93 |
| 2 | Dad | 1987-03-18 | NaN | 4210 | NaN | 1987-02-28 | 18 | 4.21 |
| 3 | Dad | 1987-03-25 | NaN | 4620 | NaN | 1987-02-28 | 25 | 4.62 |
| 4 | Dad | 1987-04-01 | NaN | 5050 | NaN | 1987-02-28 | 32 | 5.05 |
Weights¶
In [3]:
fig = px.line(
data_frame=df_m, x="age_days", y = "weight_kg", color = "name", markers=True,
width = 800, height=500,
labels={"weight_kg": "Weight (kg)", "age_days":"Age (days)"},
title="Weight vs. age tracker",
hover_name="name",
hover_data={"name": False}
)
fig.update_layout(
title_font_size = 20,
title_x = 0.5
)
fig.show()
Heights¶
In [4]:
fig = px.line(
data_frame=df_m, x="age_days", y = "height_cm", color = "name", markers=True,
width = 800, height=500,
labels={"height_cm": "Height (cm)", "age_days":"Age (days)"},
title="Height vs. age tracker",
hover_name="name",
hover_data={"name": False}
)
fig.update_layout(
title_font_size = 20,
title_x = 0.5
)
fig.show()